package com.terenac;

import java.io.IOException;
import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class KontaktiAdapter extends ArrayAdapter<String> {
	private Context context;

	private ImageView statusIcon;
	private TextView kontaktName;
	private List<String> kontaktiImena;
	
	public KontaktiAdapter (Context context, int textViewResourceId,
			List<String> objects) {
		super(context, textViewResourceId, objects);
		this.context = context;
		this.kontaktiImena = objects;
	}
	public String getItem(int index) {
		return this.kontaktiImena.get(index);
	}
	public View getView(int position, View convertView, ViewGroup parent){
		View row = convertView;
		if (row == null) {
			// ROW INFLATION
			//Log.d(tag, "Starting XML Row Inflation ... ");
			LayoutInflater inflater = (LayoutInflater) this.getContext()
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			row = inflater.inflate(R.layout.kontakti, parent, false);
			//Log.d(tag, "Successfully completed XML Row Inflation!");
		}

		// Get item
		String ime = getItem(position);
		statusIcon = (ImageView) row.findViewById(R.id.icon);
		kontaktName = (TextView) row.findViewById(R.id.label);

		kontaktName.setText(ime);
		
		statusIcon.setImageResource(R.drawable.human);

		return row;
	}

}
